{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "import csv\n",
    "with open('fujun.csv',mode='w') as file:\n",
    "    name={'name','dept','birthmonth'}\n",
    "    writer=csv.DictWriter(file,fieldnames=name)\n",
    "#     writer.writeheader()\n",
    "    writer.writeheader()\n",
    "    writer.writerow({'name':'夫君','dept':'accouting','birthmonth':'march'})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['Dialect', 'DictReader', 'DictWriter', 'Error', 'OrderedDict', 'QUOTE_ALL', 'QUOTE_MINIMAL', 'QUOTE_NONE', 'QUOTE_NONNUMERIC', 'Sniffer', 'StringIO', '_Dialect', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '__version__', 'excel', 'excel_tab', 'field_size_limit', 'get_dialect', 'list_dialects', 're', 'reader', 'register_dialect', 'unix_dialect', 'unregister_dialect', 'writer']\n",
      "Help on DictReader in module csv object:\n",
      "\n",
      "class DictReader(builtins.object)\n",
      " |  DictReader(f, fieldnames=None, restkey=None, restval=None, dialect='excel', *args, **kwds)\n",
      " |  \n",
      " |  Methods defined here:\n",
      " |  \n",
      " |  __init__(self, f, fieldnames=None, restkey=None, restval=None, dialect='excel', *args, **kwds)\n",
      " |      Initialize self.  See help(type(self)) for accurate signature.\n",
      " |  \n",
      " |  __iter__(self)\n",
      " |  \n",
      " |  __next__(self)\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data descriptors defined here:\n",
      " |  \n",
      " |  __dict__\n",
      " |      dictionary for instance variables (if defined)\n",
      " |  \n",
      " |  __weakref__\n",
      " |      list of weak references to the object (if defined)\n",
      " |  \n",
      " |  fieldnames\n",
      "\n",
      "None\n",
      "夫君\n"
     ]
    }
   ],
   "source": [
    "import pandas\n",
    "import csv\n",
    "df=open('fujun.csv','r')\n",
    "print(dir(csv))\n",
    "\n",
    "res=csv.DictReader(df)\n",
    "print(help(res))\n",
    "for i in res:\n",
    "    print(i['name'])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
